#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

int main()
{
	int fd[2];
	int ret=pipe(fd);
	if(ret<0){
		perror("pipe");
		return 1;
	}
	if(fork()==0){
		close(fd[0]);
		char* msg="hello";
		while(1){
			sleep(1);
			write(fd[1],msg,strlen(msg));
		}
		close(fd[1]);
	}
	 if(fork()<0){
		perror("fork");
		return 1;
	}
	char buf[1024]={0};
	close(fd[1]);
	int s=0;
	while(1){
		 s=read(fd[0],buf,sizeof(buf)-1);
		 printf("%s\n",buf);
	}
	
}







